package modules.lock.synchronized1;

/**
 *
 * 票 - 资源类
 * @author shengren.yan
 * @create 2021-03-05
 */
public class Ticket1 {

    private int number = 30;

    // 1.传统 synchronized  卖票的方法
    public synchronized void doTicket(){
        if(number > 0){
            System.out.println(Thread.currentThread().getName() + " 线程：卖出第" + (number--) + "" +
                    " ,还有这些票：" + number);
        }
    }

}
